<?php
/**
 * GameModel
 * 
 * @author Admin
 * @version 
 */
require_once 'Zend/Db/Table/Abstract.php';
class Wap_Models_HoSoModel extends Zend_Db_Table_Abstract
{
    /**
     * The default table name 
     */
    protected $_name = 'tbl_hoso_online';
    protected $_primary = 'id';

	function listpage($UserID){
        $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        $mySql = $db->select()->from($this->_name)->order('id DESC')->where('UserID = ?',$UserID);

        $result = $db->fetchAll($mySql);
        return $result;
    }
	
    function addPage($data){
       $db = Zend_Db_Table_Abstract::getDefaultAdapter();
       
    	$mySql = $db->insert($this->_name, $data); 
    	return $mySql;
    }
    

    function delpage($id){
         $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        try{
        $mySql = $db->delete($this->_name, ' id ='.$id);
        }catch(Exception $e){
            echo $e;
        }
        return $mySql;
    }

    function loadpagebyid($id){
         $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        $mySql = $db->select()->from($this->_name)->where('id = '.$id);
//        echo $mySql;
//        die;
        $result = $db->fetchRow($mySql);
        return $result;
    }
    
    function updatepage($data,$id){
        $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        $mySql=$db->update($this->_name, $data, 'id='.$id);
        return $mySql;
    }

    
}